<template>
    <div class="logins">
        <div class="box">
            <div class="shou">扫码点餐商户端</div>
            <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="80px" class="demo-ruleForm">
            <el-form-item label="账号" prop="account">
                <el-input v-model="ruleForm.account"></el-input>
            </el-form-item>
            <el-form-item label="密码" prop="password">
                <el-input v-model="ruleForm.password" type="password" show-password></el-input>
            </el-form-item>
            <div class="zhuce" @click="isshow">
                {{show?"注册":"登录"}}
            </div>
            <el-form-item>
                <el-button type="success" @click="login">{{show?"登录":"注册"}}</el-button>
            </el-form-item>
            </el-form>
        </div>
    </div>
</template>

<script> 
export default { 
    data() {
        return {
            show:true,
            ruleForm: {
                account: '17600000000',
                password: 's123456'
            },
            rules: {
                account: [
                    { required: true, message: '请输入账号', trigger: 'blur' }, 
                ],
                password: [
                    { required: true, message: '请输入密码', trigger: 'blur' },
                    { min: 6, max: 16, message: '长度在 6 到 16 个字符', trigger: 'blur' }
                ],
            }
        };
    },

    mounted() {
        
    },
    methods: {
        //切换
        isshow(){
            this.show=!this.show;
        },
        async login(){
            await this.$store.dispatch("use/loginasync",this.ruleForm)
            this.$message.success('登录成功')
            this.$router.push("/home")
        }
    },
};
</script>

<style lang="scss" scoped>
.logins{
    width: 100%;
    height: 100%;
    background: url("../assets/27.jpg");
    background-size: 100%;
    .box{
        width: 400px;
        height: 300px;
        background: #f2dd8c;
        position: fixed; 
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        .el-form{
            width: 90%;
            .zhuce{
                text-align: right;
                padding-bottom: 10px;
            }
            .el-button{
                margin: 0 auto;
                width: 200px;
                margin-left: 35px;
            }
        }
        .shou{
            font-size: 20px;
            font-weight: 520;
            text-align: center;
            // border: 1px solid #000;
            padding: 20px 0;
        }

    }
}
</style>